//
//  TabBarController.m
//  CJRailTransport
//
//  Created by Hank on 2017/12/21.
//  Copyright © 2017年 amplity. All rights reserved.
//

#import "TabBarController.h"
#import "UITabBarController+AddChildVC.h"
#import "BasicNavigationController.h"
#import "TrainShiftVC.h"
#import "MassLossVC.h"
#import "MeVC.h"

@interface TabBarController ()

@end

@implementation TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configureTabBar];
    
    [self configureChildViewControllers];
}

- (void)configureTabBar
{
    //    self.tabBar.shadowImage = [UIImage imageNamed:@"tabbartop-line"];
    //    if (kIsIOS8Later) {
    //        [self.tabBar setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithRed:238/255.0 green:240/255.0 blue:245/255.0 alpha:0.78]]];
    //        // blur效果
    //        UIVisualEffectView *visualEfView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
    //        visualEfView.frame = CGRectMake(0, -1, CGRectGetWidth(self.tabBar.frame), CGRectGetHeight(self.tabBar.frame)+1);
    //        visualEfView.alpha = 1.0;
    //        [self.tabBar insertSubview:visualEfView atIndex:0];
    //    }
    
    [[UITabBarItem appearanceWhenContainedIn:[TabBarController class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor colorWithRed:113/255.0 green:113/255.0 blue:113/255.0 alpha:1.0] } forState:UIControlStateNormal];
    
    [[UITabBarItem appearanceWhenContainedIn:[TabBarController class], nil] setTitleTextAttributes:@{NSForegroundColorAttributeName :GreenColor } forState:UIControlStateSelected];
}

- (void)configureChildViewControllers
{
    // 首页
    [self addHomeController];
    // 质损
    [self addMassLossController];
    // 我
    [self addMeController];
}

- (void)addHomeController
{
    TrainShiftVC *trainShiftVC = [[TrainShiftVC alloc]init];
    
    [self addChildViewController:trainShiftVC title:@"首页" image:@"login_userName" selectedImage:@"login_userName" imageInsets:[self imageInsets] titlePosition:[self titlePosition] navControllerClass:[BasicNavigationController class]];
}

- (void)addMassLossController
{
    MassLossVC *massLossVC = [[MassLossVC alloc]init];
    
    [self addChildViewController:massLossVC title:@"质损" image:@"login_userName" selectedImage:@"login_userName" imageInsets:[self imageInsets] titlePosition:[self titlePosition] navControllerClass:[BasicNavigationController class]];
}

- (void)addMeController
{
    MeVC *meVC = [[MeVC alloc]init];
    
    [self addChildViewController:meVC title:@"我" image:@"login_userName" selectedImage:@"login_userName" imageInsets:[self imageInsets] titlePosition:[self titlePosition] navControllerClass:[BasicNavigationController class]];
}
// 图片偏移
- (UIEdgeInsets)imageInsets
{
    return UIEdgeInsetsZero;
}
// 标题偏移
- (UIOffset)titlePosition
{
    return UIOffsetMake(0, -2);
}

@end
